package com.edu.controller;


import com.edu.entity.subject.OneSubject;
import com.edu.service.SubjectService;
import com.edu.utils.R;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author mxs
 * @since 2021-10-18
 */
@Api("课程分类管理")
@RestController
@CrossOrigin
@RequestMapping("/edu/subject")
public class SubjectController {
    @Autowired
    SubjectService subjectService;

    /**
     * 读取excel表格中的数据
     * @param file 上传的excel表格
     * @return
     */
    @PostMapping("/addSubject")
    public R addSubject(MultipartFile file){
        subjectService.importSubjectData(file,subjectService);
        return R.success();
    }

    /**
     * 获取所有课程分类
     * @return
     */
    @GetMapping("/getSubject")
    public R getSubject(){
        List<OneSubject> list = subjectService.getAllOneTwoSubject();
        return R.success().data("list",list);
    }


}

